package com.qianfeng.job;

import org.quartz.JobKey;
import org.quartz.SchedulerException;
import org.quartz.impl.StdScheduler;
import org.quartz.impl.matchers.GroupMatcher;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DemoTest2 {

    public static void main(String[] args) throws InterruptedException, SchedulerException {
        //实例化容器
        ClassPathXmlApplicationContext ioc = new ClassPathXmlApplicationContext("spring2.xml");
        //调度器
        StdScheduler stdScheduler = (StdScheduler) ioc.getBean("scheduler");
        //获取某一组任务
        GroupMatcher<JobKey> group1  = GroupMatcher.groupEquals("g1");
        //运行五秒之后暂停
        Thread.sleep(5000);

        stdScheduler.pauseJobs(group1);
        //暂停五秒之后再重启
        Thread.sleep(5000);
        stdScheduler.resumeJobs(group1);
    }
}
